<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>发布招工信息 - 上传辅助资料</title>
    <script src="https://cdn.tailwindcss.com/3.3.3"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css">
    <style>
        body {
            font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
            background-color: #f8f9fa;
            color: #333;
        }
        .upload-area {
            border: 2px dashed #d1d5db;
            transition: all 0.3s ease;
        }
        .upload-area:hover {
            border-color: #3b82f6;
            background-color: #f0f7ff;
        }
        .thumbnail {
            aspect-ratio: 1/1;
            object-fit: cover;
        }
        .step-indicator .active {
            color: #3b82f6;
            font-weight: 600;
        }
        .step-indicator .completed {
            color: #10b981;
        }
        .btn-primary {
            background-color: #3b82f6;
            transition: all 0.2s ease;
        }
        .btn-primary:hover {
            background-color: #2563eb;
        }
        .btn-outline {
            border: 1px solid #d1d5db;
            transition: all 0.2s ease;
        }
        .btn-outline:hover {
            background-color: #f3f4f6;
        }
    </style>
</head>
<body class="max-w-[750px] mx-auto bg-white min-h-screen">
    <!-- 顶部步骤指示器 -->
    <div class="px-6 py-4 border-b border-gray-200">
        <div class="flex justify-between items-center step-indicator text-sm text-gray-500">
            <div class="flex items-center">
                <div class="w-6 h-6 rounded-full bg-green-100 flex items-center justify-center text-green-600 mr-2">
                    <i class="fas fa-check text-xs"></i>
                </div>
                <span class="completed">1. 填写信息</span>
            </div>
            <div class="flex items-center">
                <div class="w-6 h-6 rounded-full bg-blue-100 flex items-center justify-center text-blue-600 mr-2">
                    <span class="text-sm">2</span>
                </div>
                <span class="active">2. 上传资料</span>
            </div>
            <div class="flex items-center">
                <div class="w-6 h-6 rounded-full bg-gray-100 flex items-center justify-center text-gray-400 mr-2">
                    <span class="text-sm">3</span>
                </div>
                <span>3. 确认发布</span>
            </div>
        </div>
    </div>

    <!-- 主内容区 -->
    <main class="px-6 py-4">
        <h1 class="text-xl font-bold mb-6">上传辅助资料</h1>
        
        <!-- 工作环境照片上传 -->
        <div class="mb-8">
            <h2 class="text-lg font-semibold mb-3 flex items-center">
                <span class="w-5 h-5 bg-blue-500 rounded-full flex items-center justify-center text-white text-xs mr-2">1</span>
                工作环境照片
            </h2>
            <p class="text-sm text-gray-500 mb-3">清晰的工作环境照片可提高接单率（至少1张）</p>
            
            <div id="photoUpload" class="upload-area rounded-lg p-6 text-center cursor-pointer mb-4">
                <div class="flex flex-col items-center justify-center py-8">
                    <i class="fas fa-cloud-upload-alt text-4xl text-blue-500 mb-3"></i>
                    <p class="font-medium">点击或拖拽上传照片</p>
                    <p class="text-sm text-gray-500 mt-1">支持JPG/PNG格式</p>
                </div>
                <input type="file" multiple accept="image/*" class="hidden">
            </div>
            
            <p class="text-sm text-gray-500 mb-3">示例图引导：如：客厅环境、卧室环境、厨房环境</p>
            
            <!-- 照片预览区 -->
            <div id="photoPreview" class="grid grid-cols-3 gap-3">
                <!-- 这里会动态生成上传的照片缩略图 -->
                <div class="border border-gray-200 rounded-lg overflow-hidden relative hidden">
                    <img src="" alt="上传的图片" class="thumbnail w-full h-full">
                    <button class="absolute top-1 right-1 bg-red-500 text-white rounded-full w-5 h-5 flex items-center justify-center">
                        <i class="fas fa-times text-xs"></i>
                    </button>
                </div>
            </div>
        </div>
        
        <!-- 技能要求视频上传 -->
        <div class="mb-8">
            <h2 class="text-lg font-semibold mb-3 flex items-center">
                <span class="w-5 h-5 bg-blue-500 rounded-full flex items-center justify-center text-white text-xs mr-2">2</span>
                技能要求视频（可选）
            </h2>
            
            <div id="videoUpload" class="upload-area rounded-lg p-6 text-center cursor-pointer mb-2">
                <div class="flex flex-col items-center justify-center py-8">
                    <i class="fas fa-video text-4xl text-blue-500 mb-3"></i>
                    <p class="font-medium">点击上传视频</p>
                    <p class="text-sm text-gray-500 mt-1">支持MP4格式，不超过50MB</p>
                </div>
                <input type="file" accept="video/mp4" class="hidden">
            </div>
            
            <!-- 视频预览区 -->
            <div id="videoPreview" class="hidden">
                <div class="relative">
                    <video controls class="w-full rounded-lg">
                        <source src="" type="video/mp4">
                    </video>
                    <button class="absolute top-1 right-1 bg-red-500 text-white rounded-full w-5 h-5 flex items-center justify-center">
                        <i class="fas fa-times text-xs"></i>
                    </button>
                </div>
            </div>
        </div>
        
        <!-- 其他辅助资料 -->
        <div class="mb-8">
            <h2 class="text-lg font-semibold mb-3 flex items-center">
                <span class="w-5 h-5 bg-blue-500 rounded-full flex items-center justify-center text-white text-xs mr-2">3</span>
                其他辅助资料（可选）
            </h2>
            
            <div class="space-y-3 mb-4">
                <label class="flex items-center">
                    <input type="checkbox" class="rounded text-blue-500 mr-2">
                    <span>服务合同模板</span>
                </label>
                <label class="flex items-center">
                    <input type="checkbox" class="rounded text-blue-500 mr-2">
                    <span>住户须知文档</span>
                </label>
                <label class="flex items-center">
                    <input type="checkbox" class="rounded text-blue-500 mr-2">
                    <span>特殊技能证书要求</span>
                </label>
            </div>
            
            <div id="docUpload" class="upload-area rounded-lg p-4 text-center cursor-pointer">
                <div class="flex flex-col items-center justify-center py-4">
                    <i class="fas fa-file-pdf text-3xl text-red-500 mb-2"></i>
                    <p class="font-medium">点击上传PDF文件</p>
                </div>
                <input type="file" accept=".pdf" class="hidden">
            </div>
            
            <!-- 文档预览区 -->
            <div id="docPreview" class="mt-3 hidden">
                <div class="flex items-center justify-between bg-gray-50 p-3 rounded-lg">
                    <div class="flex items-center">
                        <i class="fas fa-file-pdf text-red-500 text-xl mr-2"></i>
                        <div>
                            <p class="font-medium text-sm">上传的文件.pdf</p>
                            <p class="text-xs text-gray-500">1.2MB</p>
                        </div>
                    </div>
                    <button class="text-gray-400 hover:text-red-500">
                        <i class="fas fa-times"></i>
                    </button>
                </div>
            </div>
        </div>
    </main>
    
    <!-- 底部操作栏 -->
    <div class="fixed bottom-0 left-0 right-0 max-w-[750px] mx-auto bg-white border-t border-gray-200 px-6 py-3 flex justify-between items-center">
        <div class="text-sm text-gray-500">已完成 2/3</div>
        <div class="flex space-x-3">
            <button class="btn-outline px-6 py-2 rounded-lg">上一步</button>
            <button class="btn-primary text-white px-6 py-2 rounded-lg">下一步</button>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 照片上传逻辑
            const photoUpload = document.getElementById('photoUpload');
            const photoInput = photoUpload.querySelector('input[type="file"]');
            const photoPreview = document.getElementById('photoPreview');
            const photoTemplate = photoPreview.querySelector('div');
            
            photoUpload.addEventListener('click', function() {
                photoInput.click();
            });
            
            photoInput.addEventListener('change', function(e) {
                const files = e.target.files;
                if (files.length > 0) {
                    // 清空预览区
                    photoPreview.innerHTML = '';
                    
                    // 限制最多9张
                    const maxFiles = Math.min(files.length, 9);
                    
                    for (let i = 0; i < maxFiles; i++) {
                        const file = files[i];
                        if (file.type.match('image.*')) {
                            const reader = new FileReader();
                            
                            reader.onload = function(e) {
                                const clone = photoTemplate.cloneNode(true);
                                clone.classList.remove('hidden');
                                clone.querySelector('img').src = e.target.result;
                                
                                // 添加删除按钮事件
                                clone.querySelector('button').addEventListener('click', function() {
                                    clone.remove();
                                });
                                
                                photoPreview.appendChild(clone);
                            }
                            
                            reader.readAsDataURL(file);
                        }
                    }
                }
            });
            
            // 视频上传逻辑
            const videoUpload = document.getElementById('videoUpload');
            const videoInput = videoUpload.querySelector('input[type="file"]');
            const videoPreview = document.getElementById('videoPreview');
            
            videoUpload.addEventListener('click', function() {
                videoInput.click();
            });
            
            videoInput.addEventListener('change', function(e) {
                const file = e.target.files[0];
                if (file && file.type.match('video.*')) {
                    const reader = new FileReader();
                    
                    reader.onload = function(e) {
                        videoPreview.classList.remove('hidden');
                        videoPreview.querySelector('video source').src = e.target.result;
                        
                        // 添加删除按钮事件
                        videoPreview.querySelector('button').addEventListener('click', function() {
                            videoPreview.classList.add('hidden');
                            videoInput.value = '';
                        });
                    }
                    
                    reader.readAsDataURL(file);
                }
            });
            
            // 文档上传逻辑
            const docUpload = document.getElementById('docUpload');
            const docInput = docUpload.querySelector('input[type="file"]');
            const docPreview = document.getElementById('docPreview');
            
            docUpload.addEventListener('click', function() {
                docInput.click();
            });
            
            docInput.addEventListener('change', function(e) {
                const file = e.target.files[0];
                if (file && file.name.match(/\.pdf$/i)) {
                    docPreview.classList.remove('hidden');
                    docPreview.querySelector('p').textContent = file.name;
                    docPreview.querySelector('p + p').textContent = (file.size / (1024 * 1024)).toFixed(1) + 'MB';
                    
                    // 添加删除按钮事件
                    docPreview.querySelector('button').addEventListener('click', function() {
                        docPreview.classList.add('hidden');
                        docInput.value = '';
                    });
                }
            });
            
            // 底部按钮事件
            document.querySelector('.btn-outline').addEventListener('click', function() {
                window.location.href = 'job-publish-step1.html';
            });
            
            document.querySelector('.btn-primary').addEventListener('click', function() {
                window.location.href = 'job-publish-step3.html';
            });
        });
    </script>
</body>
</html>